<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 1. 继承父构造函数的this上面挂的东西
        function Parent (uname, age) {
            this.uname = uname;
            this.age = age;
        }

        Parent.prototype.b = 2;

        function Child (uname, age) {
            // 模仿super
            // 继承第一步
            Parent.apply(this, [uname, age]);
        }

        Child.prototype.a = 1;

        // 2. 继承Parent.prototype上面挂的东西
        // Child.prototype = Parent.prototype;

        // 在原有地址的基础上 合并对象
        // for (const key in Parent.prototype) {
        //     Child.prototype[key] = Parent.prototype[key];
        // }

        Object.assign(Child.prototype, Parent.prototype);

        // console.log(Child.prototype); // { a: 1, b: 2 }
        // console.log(Parent.prototype); // { b: 2 }

        const c = new Child('zhangsan', 18);

        console.log(c.b);


    </script>
</body>
</html>